---
layout: "default"
title: "Decodable"
description: "Swift documentation for 'Decodable': A type that can decode itself from an external representation."
keywords: "Decodable,protocol,swift,documentation"
root: "/v4.2"
---

<div class="intro-declaration"><code class="language-swift">protocol Decodable</code></div>

<div class="discussion comment">
    <p>A type that can decode itself from an external representation.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>



<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init-from_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-from_">init(<wbr>from:)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init-from_"><div class="p">
    <p>Creates a new instance by decoding from the given decoder.</p>

<p>This initializer throws an error if reading from the decoder fails, or
if the data read is corrupted or otherwise invalid.</p>

<p><strong><code>decoder</code>:</strong>  The decoder to read data from.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(from decoder: Decoder)</code>

    </div></div>
</div>







